package org.bot.server.log.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.bot.server.log.entity.BotClientLogInfo;
import org.bot.server.log.mapper.BotClientLogInfoMapper;
import org.bot.server.log.mapper.BotClientLogMapper;
import org.bot.server.log.service.BotClientLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 沧月
 * @create 0020 2023/10/20 10:35
 * @description <description class purpose>
 */
@Service
public class BotClientLogServiceImpl implements BotClientLogService {

    @Autowired
    BotClientLogMapper botClientLogMapper;


    @Autowired
    BotClientLogInfoMapper botClientLogInfoMapper;

    @Override
    public List<Map<String, Object>> getLog(Integer flowId, Integer page, Integer size) {
        return botClientLogMapper.list(flowId, (page - 1) * size, size);
    }

    @Override
    public List<BotClientLogInfo> getLogInfo(String logId) {
        QueryWrapper<BotClientLogInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("batch_id", logId);
        wrapper.orderByAsc("flow_order");
        return botClientLogInfoMapper.selectList(wrapper);
    }

    @Override
    public int listCount(Integer flowId) {
        return botClientLogMapper.count(flowId);
    }

    @Override
    public List<Map<String, Object>> flowList(Integer clientId) {
        return botClientLogMapper.flowList(clientId);
    }
}
